package com.blkbox.javase.asynchronous.ex1;

public class Producer {
	private boolean ok;
	private String product;

	public synchronized void makeProduce() throws InterruptedException {
		if (ok) {
			return;
		} else {
			Thread.sleep(1000);
		}
		ok = true;
		notifyAll();
		product = "p1";
	}

	public synchronized String getProduct() throws InterruptedException {
		if (!ok) {
			wait();
		}
		return product;

	}

}
